package com.blog.controller.adminarticle;

import java.io.IOException;
import java.sql.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blog.controller.base.BaseServlet;
import com.blog.entity.AdminBlogerEntity;
import com.blog.entity.BlogerConditionEntity;
import com.blog.service.adminbloggers.AdminBlogerService;

@WebServlet("/adminArtical/blogerManager")
public class AdminBlogerManagerServlet extends BaseServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		AdminBlogerService service=new AdminBlogerService();
		BlogerConditionEntity e=new BlogerConditionEntity();
		Date startTime=req.getParameter("startTime")==null?null:Date.valueOf(req.getParameter("startTime"));
		Date endTime=req.getParameter("endTime")==null?null:Date.valueOf(req.getParameter("endTime"));
		String key=req.getParameter("key")==null?null:req.getParameter("key");
		Integer status=req.getParameter("status")==null?0:Integer.parseInt(req.getParameter("status"));
		e.setEndTime(endTime);
		e.setStartTime(startTime);
		e.setKey(key);
		e.setStatus(status);
		List<AdminBlogerEntity> blogers=service.getBloger(e);
		req.setAttribute("blogers",blogers );
		forward("admin/blogermanager");
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}
